from selenium import webdriver
from selenium.webdriver.common.keys import Keys

def get_driver():
    '''获得浏览器驱动对象'''
    chromedriver = 'chromedriver'
    driver = webdriver.Chrome(executable_path=chromedriver)
    return driver

driver = get_driver()
driver.get('https://www.google.com')
# 通过class name定位搜索框元素
search_input = driver.find_element_by_class_name('gLFyf')
# 在搜索框内输入「python」
search_input.send_keys('python')
# 在搜索框内敲击回车键
search_input.send_keys(Keys.ENTER)
